<?php

	class Scope {
		
		public function __construct() { }
		
		public static function loadVar($name) { 
			
			if( self::loadGetVar($name) != null ) {
				return self::loadGetVar($name);
			} else if( self::loadPostVar($name) != null ) {
				return self::loadPostVar($name);
			} else if( self::loadCookieVar($name) != null ) {
				return self::loadCookieVar($name);
			} else if( self::loadSessionVar($name) != null ) {
				return self::loadSessionVar($name);
			} else {
				return null;
			}
		}
		
		public static function loadPostVar($name) {
			return isset($_POST[$name]) ? $_POST[$name] : null;
		}
		
		public static function loadGetVar($name) {
			return isset($_GET[$name]) ? $_GET[$name] : null;
		}
		
		public static function loadSessionVar($name) {
			@session_start();
			return isset($_SESSION[$name]) ? $_SESSION[$name] : null;
		}
		
		public static function loadCookieVar($name) {
			return isset($_COOKIE[$name]) ? $_COOKIE[$name] : null;
		}
		
		public static function putCookieVar($name,$value) {
			$_COOKIE[$name] = $value;
		}
		
		public static function putPostVar($name,$value) {
			$_POST[$name] = $value;
		}
		
		public static function putGetVar($name,$value) {
			$_GET[$name] = $value;
		}
		
		public static function putSessionVar($name,$value) {
			session_start();
			$_SESSION[$name] = $value;
			session_write_close();
		}
	}
?>